package com.atguigu.ssyx.sys.controller;


import com.atguigu.ssyx.common.result.Result;
import com.atguigu.ssyx.model.sys.Region;
import com.atguigu.ssyx.model.sys.RegionWare;
import com.atguigu.ssyx.sys.service.IRegionService;
import com.atguigu.ssyx.sys.service.IRegionWareService;
import com.atguigu.ssyx.vo.sys.RegionWareQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 地区表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-09-13
 */
@RestController
@RequestMapping("/admin/sys/region")
@Api(tags = "区域管理")
//@CrossOrigin
@RequiredArgsConstructor
public class RegionController {
    private final IRegionService regionService;


    /*  url: `${api_name}/findRegionByKeyword/${keyword}`,
      method: 'get'*/
    @ApiOperation("根据区域关键字查询地区信息")
    @GetMapping("/findRegionByKeyword/{keyword}")
    public Result findRegionByKeyword(@PathVariable("keyword") String keyword) {
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        if (!StringUtils.isEmpty(keyword)) {
            wrapper.like(Region::getName, keyword);
        }
        return Result.ok(regionService.list(wrapper));

    }
}
